package com.android.pagemarket.ui.adapter;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.android.pagemarket.R;
import com.android.pagemarket.business.model.Adv;
import com.android.pagemarket.ui.widget.AdvView;

/*********************************************************
 * @author : zhaohua
 * @version : 2012-8-16
 * @see : 广告图片列表适配器
 * @Copyright : copyrights reserved by personal 2007-2011
 **********************************************************/
public class AdvListAdapter extends ArrayListAdapter<Adv>
{
    private LayoutInflater mInflater;
    
    public AdvListAdapter(Context context)
    {
        super(context);
        mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent)
    {
        convertView = mInflater.inflate(R.layout.view_image, null);
        AdvView advView = (AdvView)convertView.findViewById(R.id.image);
        advView.bindData((Adv)getItem(position));
        return convertView;
    }
    
    public void loadMainAdvs()
    {
        Adv one1 = new Adv();
        one1.advType = 1;
        one1.imgRid = R.drawable.ic_pic0;
        Adv one2 = new Adv();
        one2.imgRid = R.drawable.ic_pic1;
        Adv one3 = new Adv();
        one3.imgRid = R.drawable.ic_pic2;
        Adv one4 = new Adv();
        one4.imgRid = R.drawable.ic_pic3;
        
        Adv list[] = new Adv[4];
        list[0] = one1;
        list[1] = one2;
        list[2] = one3;
        list[3] = one4;
        
        addItems(list);
    }
}
